package org.zhao.nettydemos.lab05;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.RunnableFuture;

/**
 * @Auther: xiaohui.zhao
 * @Date: 2021/9/17 15:27
 * @Description:  使用FutureTask + 线程获取异步结果
 */
public class FutureTaskTest {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask = new FutureTask<>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                return "测试futureTask获取异步结果";
            }
        });

        new Thread(futureTask).start();
        System.out.println(futureTask.get());
    }

}